package myhomework;

import java.lang.annotation.Target;
import java.util.Arrays;
import java.util.Scanner;

public class Work11 {
    public static void main(String[] args) {
        String[] names = new String[5];
        Scanner scanner = new Scanner(System.in);
        String target=scanner.nextLine();
        String target2=scanner.nextLine();
        names[0] = "坤坤";
        names[1] = "zs";
        names[2] = "彭于晏";
        names[3] = "吴彦祖";
        names[4] = "MM";
        arrayTraversal(names);//遍历
        System.out.println(addName(names,target));//增
        deletName(names,target2);//删
        arrayTraversal(names);
    }


    //遍历数组
    public static void arrayTraversal(String[] names){
        for (String name : names) {
            System.out.print(name+"  ");
        }
        System.out.println();
    }

    //增
    public static int addName(String[] names,String target){
        int i;
        for (i = 0; i < names.length; i++) {
            if(names[i]==null){
                break;
            }
        }
        if(i<names.length){
            names[i]=target;
            return 0;//成功
        }
        System.out.println("inser false");
        return -1;//失败

    }

    //删
    public static void deletName(String[] names,String target){
        int i;
        for ( i = 0; i <names.length ; i++) {
            if(names[i]==null||!names[i].equals(target)){
                continue;
            }
            break;
        }
        for (;i<=names.length-1;i++){
            if(i==names.length-1){
                names[i]=null;
                break;
            }
            names[i]=names[i+1];
        }
    }
}
